<UserControl x:Class="ThScoreFileConverter.Views.SettingWindow"
             xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
        	 xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
        	 xmlns:i="http://schemas.microsoft.com/expression/2010/interactivity"
        	 xmlns:a="clr-namespace:ThScoreFileConverter.Actions"
        	 xmlns:c="clr-namespace:ThScoreFileConverter.Commands"
             FocusManager.FocusedElement="{Binding ElementName=OkButton}"
             UseLayoutRounding="True">

    <UserControl.InputBindings>
        <KeyBinding Command="{x:Static c:CloseWindowCommand.Instance}"
                    CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
                    Key="Escape"/>
    </UserControl.InputBindings>

    <StackPanel Margin="10"
                Style="{StaticResource VerticalStackPanelStyle}">
        <GroupBox Header="フォント設定">
            <StackPanel Style="{StaticResource HorizontalStackPanelStyle}">
                <TextBox IsReadOnly="True"
                         MinWidth="190"
                         Text="{Binding Font, Mode=OneWay}"/>
                <Separator/>
                <Button Content="変更(_C)...">
                    <i:Interaction.Triggers>
                        <i:EventTrigger EventName="Click">
                            <a:FontDialogAction ApplyCommand="{Binding FontDialogApplyCommand}"
                                                CancelCommand="{Binding FontDialogCancelCommand}"
                                                Font="{Binding Font}"
                                                FontMustExist="True"
                                                OkCommand="{Binding FontDialogOkCommand}"
                                                Owner="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"
                                                ShowApply="True"
                                                ShowEffects="False"/>
                        </i:EventTrigger>
                    </i:Interaction.Triggers>
                </Button>
                <Separator/>
                <Button Command="{Binding ResetFontCommand}"
                        Content="リセット(_R)"/>
            </StackPanel>
        </GroupBox>

        <Separator/>

        <GroupBox Header="出力書式設定">
            <CheckBox Content="数値を桁区切り形式で出力する(_S)"
                      IsChecked="{Binding OutputNumberGroupSeparator}"/>
        </GroupBox>

        <Separator/>

        <GroupBox Header="文字エンコーディング設定">
            <Grid>
                <Grid.ColumnDefinitions>
                    <ColumnDefinition Width="*"/>
                    <ColumnDefinition Width="*"/>
                </Grid.ColumnDefinitions>
                <Grid.RowDefinitions>
                    <RowDefinition Height="auto"/>
                    <RowDefinition Height="auto"/>
                </Grid.RowDefinitions>
                <Label Content="入力ファイル(_I):"
                       HorizontalAlignment="Left"
                       Target="{Binding ElementName=InputEncodingsComboBox, Mode=OneWay}"
                       VerticalAlignment="Center"/>
                <ComboBox x:Name="InputEncodingsComboBox"
                          Grid.Column="1"
                          DisplayMemberPath="Value"
                          ItemsSource="{Binding InputEncodings}"
                          SelectedValue="{Binding InputCodePageId, Mode=TwoWay}"
                          SelectedValuePath="Key"
                          VerticalAlignment="Center"/>
                <Label Grid.Row="1"
                       Content="出力ファイル(_O):"
                       HorizontalAlignment="Left"
                       Target="{Binding ElementName=OutputEncodingsComboBox, Mode=OneWay}"
                       VerticalAlignment="Center"/>
                <ComboBox x:Name="OutputEncodingsComboBox"
                          Grid.Column="1"
                          Grid.Row="1"
                          DisplayMemberPath="Value"
                          ItemsSource="{Binding OutputEncodings}"
                          SelectedValue="{Binding OutputCodePageId, Mode=TwoWay}"
                          SelectedValuePath="Key"
                          VerticalAlignment="Center"/>
            </Grid>
        </GroupBox>

        <Separator/>

        <Button x:Name="OkButton"
                Content="OK"
                HorizontalAlignment="Center"
                IsDefault="True">
            <i:Interaction.Triggers>
                <i:EventTrigger EventName="Click">
                    <i:InvokeCommandAction Command="{x:Static c:CloseWindowCommand.Instance}"
                                           CommandParameter="{Binding RelativeSource={RelativeSource FindAncestor, AncestorType={x:Type Window}}}"/>
                </i:EventTrigger>
            </i:Interaction.Triggers>
        </Button>
    </StackPanel>
</UserControl>
